package com.wetech.demo.web3j.contracts.multisignererc7913;

import io.reactivex.Flowable;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Callable;
import org.web3j.abi.EventEncoder;
import org.web3j.abi.TypeReference;
import org.web3j.abi.datatypes.Bool;
import org.web3j.abi.datatypes.CustomError;
import org.web3j.abi.datatypes.DynamicArray;
import org.web3j.abi.datatypes.DynamicBytes;
import org.web3j.abi.datatypes.Event;
import org.web3j.abi.datatypes.Function;
import org.web3j.abi.datatypes.Type;
import org.web3j.abi.datatypes.generated.Uint256;
import org.web3j.abi.datatypes.generated.Uint64;
import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameter;
import org.web3j.protocol.core.RemoteCall;
import org.web3j.protocol.core.RemoteFunctionCall;
import org.web3j.protocol.core.methods.request.EthFilter;
import org.web3j.protocol.core.methods.response.BaseEventResponse;
import org.web3j.protocol.core.methods.response.Log;
import org.web3j.protocol.core.methods.response.TransactionReceipt;
import org.web3j.tx.Contract;
import org.web3j.tx.TransactionManager;
import org.web3j.tx.gas.ContractGasProvider;

/**
 * <p>Auto generated code.
 * <p><strong>Do not modify!</strong>
 * <p>Please use the <a href="https://docs.web3j.io/command_line.html">web3j command line tools</a>,
 * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the 
 * <a href="https://github.com/LFDT-web3j/web3j/tree/main/codegen">codegen module</a> to update.
 *
 * <p>Generated with web3j version 4.14.0.
 */
@SuppressWarnings("rawtypes")
public class MultiSignerERC7913 extends Contract {
    public static final String BINARY = "";

    private static String librariesLinkedBinary;

    public static final String FUNC_GETSIGNERCOUNT = "getSignerCount";

    public static final String FUNC_GETSIGNERS = "getSigners";

    public static final String FUNC_ISSIGNER = "isSigner";

    public static final String FUNC_THRESHOLD = "threshold";

    public static final CustomError MULTISIGNERERC7913ALREADYEXISTS_ERROR = new CustomError("MultiSignerERC7913AlreadyExists", 
            Arrays.<TypeReference<?>>asList(new TypeReference<DynamicBytes>() {}));
    ;

    public static final CustomError MULTISIGNERERC7913INVALIDSIGNER_ERROR = new CustomError("MultiSignerERC7913InvalidSigner", 
            Arrays.<TypeReference<?>>asList(new TypeReference<DynamicBytes>() {}));
    ;

    public static final CustomError MULTISIGNERERC7913NONEXISTENTSIGNER_ERROR = new CustomError("MultiSignerERC7913NonexistentSigner", 
            Arrays.<TypeReference<?>>asList(new TypeReference<DynamicBytes>() {}));
    ;

    public static final CustomError MULTISIGNERERC7913UNREACHABLETHRESHOLD_ERROR = new CustomError("MultiSignerERC7913UnreachableThreshold", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint64>() {}, new TypeReference<Uint64>() {}));
    ;

    public static final CustomError MULTISIGNERERC7913ZEROTHRESHOLD_ERROR = new CustomError("MultiSignerERC7913ZeroThreshold", 
            Arrays.<TypeReference<?>>asList());
    ;

    public static final Event ERC7913SIGNERADDED_EVENT = new Event("ERC7913SignerAdded", 
            Arrays.<TypeReference<?>>asList(new TypeReference<DynamicBytes>(true) {}));
    ;

    public static final Event ERC7913SIGNERREMOVED_EVENT = new Event("ERC7913SignerRemoved", 
            Arrays.<TypeReference<?>>asList(new TypeReference<DynamicBytes>(true) {}));
    ;

    public static final Event ERC7913THRESHOLDSET_EVENT = new Event("ERC7913ThresholdSet", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint64>() {}));
    ;

    @Deprecated
    protected MultiSignerERC7913(String contractAddress, Web3j web3j, Credentials credentials,
            BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit);
    }

    protected MultiSignerERC7913(String contractAddress, Web3j web3j, Credentials credentials,
            ContractGasProvider contractGasProvider) {
        super(BINARY, contractAddress, web3j, credentials, contractGasProvider);
    }

    @Deprecated
    protected MultiSignerERC7913(String contractAddress, Web3j web3j,
            TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit);
    }

    protected MultiSignerERC7913(String contractAddress, Web3j web3j,
            TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
    }

    public static List<ERC7913SignerAddedEventResponse> getERC7913SignerAddedEvents(
            TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = staticExtractEventParametersWithLog(ERC7913SIGNERADDED_EVENT, transactionReceipt);
        ArrayList<ERC7913SignerAddedEventResponse> responses = new ArrayList<ERC7913SignerAddedEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            ERC7913SignerAddedEventResponse typedResponse = new ERC7913SignerAddedEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.signers = (byte[]) eventValues.getIndexedValues().get(0).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public static ERC7913SignerAddedEventResponse getERC7913SignerAddedEventFromLog(Log log) {
        Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(ERC7913SIGNERADDED_EVENT, log);
        ERC7913SignerAddedEventResponse typedResponse = new ERC7913SignerAddedEventResponse();
        typedResponse.log = log;
        typedResponse.signers = (byte[]) eventValues.getIndexedValues().get(0).getValue();
        return typedResponse;
    }

    public Flowable<ERC7913SignerAddedEventResponse> eRC7913SignerAddedEventFlowable(
            EthFilter filter) {
        return web3j.ethLogFlowable(filter).map(log -> getERC7913SignerAddedEventFromLog(log));
    }

    public Flowable<ERC7913SignerAddedEventResponse> eRC7913SignerAddedEventFlowable(
            DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
        EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
        filter.addSingleTopic(EventEncoder.encode(ERC7913SIGNERADDED_EVENT));
        return eRC7913SignerAddedEventFlowable(filter);
    }

    public static List<ERC7913SignerRemovedEventResponse> getERC7913SignerRemovedEvents(
            TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = staticExtractEventParametersWithLog(ERC7913SIGNERREMOVED_EVENT, transactionReceipt);
        ArrayList<ERC7913SignerRemovedEventResponse> responses = new ArrayList<ERC7913SignerRemovedEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            ERC7913SignerRemovedEventResponse typedResponse = new ERC7913SignerRemovedEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.signers = (byte[]) eventValues.getIndexedValues().get(0).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public static ERC7913SignerRemovedEventResponse getERC7913SignerRemovedEventFromLog(Log log) {
        Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(ERC7913SIGNERREMOVED_EVENT, log);
        ERC7913SignerRemovedEventResponse typedResponse = new ERC7913SignerRemovedEventResponse();
        typedResponse.log = log;
        typedResponse.signers = (byte[]) eventValues.getIndexedValues().get(0).getValue();
        return typedResponse;
    }

    public Flowable<ERC7913SignerRemovedEventResponse> eRC7913SignerRemovedEventFlowable(
            EthFilter filter) {
        return web3j.ethLogFlowable(filter).map(log -> getERC7913SignerRemovedEventFromLog(log));
    }

    public Flowable<ERC7913SignerRemovedEventResponse> eRC7913SignerRemovedEventFlowable(
            DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
        EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
        filter.addSingleTopic(EventEncoder.encode(ERC7913SIGNERREMOVED_EVENT));
        return eRC7913SignerRemovedEventFlowable(filter);
    }

    public static List<ERC7913ThresholdSetEventResponse> getERC7913ThresholdSetEvents(
            TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = staticExtractEventParametersWithLog(ERC7913THRESHOLDSET_EVENT, transactionReceipt);
        ArrayList<ERC7913ThresholdSetEventResponse> responses = new ArrayList<ERC7913ThresholdSetEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            ERC7913ThresholdSetEventResponse typedResponse = new ERC7913ThresholdSetEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.threshold = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public static ERC7913ThresholdSetEventResponse getERC7913ThresholdSetEventFromLog(Log log) {
        Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(ERC7913THRESHOLDSET_EVENT, log);
        ERC7913ThresholdSetEventResponse typedResponse = new ERC7913ThresholdSetEventResponse();
        typedResponse.log = log;
        typedResponse.threshold = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
        return typedResponse;
    }

    public Flowable<ERC7913ThresholdSetEventResponse> eRC7913ThresholdSetEventFlowable(
            EthFilter filter) {
        return web3j.ethLogFlowable(filter).map(log -> getERC7913ThresholdSetEventFromLog(log));
    }

    public Flowable<ERC7913ThresholdSetEventResponse> eRC7913ThresholdSetEventFlowable(
            DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
        EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
        filter.addSingleTopic(EventEncoder.encode(ERC7913THRESHOLDSET_EVENT));
        return eRC7913ThresholdSetEventFlowable(filter);
    }

    public RemoteFunctionCall<BigInteger> getSignerCount() {
        final Function function = new Function(FUNC_GETSIGNERCOUNT, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeRemoteCallSingleValueReturn(function, BigInteger.class);
    }

    public RemoteFunctionCall<List> getSigners(BigInteger start, BigInteger end) {
        final Function function = new Function(FUNC_GETSIGNERS, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint64(start), 
                new org.web3j.abi.datatypes.generated.Uint64(end)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<DynamicArray<DynamicBytes>>() {}));
        return new RemoteFunctionCall<List>(function,
                new Callable<List>() {
                    @Override
                    @SuppressWarnings("unchecked")
                    public List call() throws Exception {
                        List<Type> result = (List<Type>) executeCallSingleValueReturn(function, List.class);
                        return convertToNative(result);
                    }
                });
    }

    public RemoteFunctionCall<Boolean> isSigner(byte[] signer) {
        final Function function = new Function(FUNC_ISSIGNER, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.DynamicBytes(signer)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Bool>() {}));
        return executeRemoteCallSingleValueReturn(function, Boolean.class);
    }

    public RemoteFunctionCall<BigInteger> threshold() {
        final Function function = new Function(FUNC_THRESHOLD, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint64>() {}));
        return executeRemoteCallSingleValueReturn(function, BigInteger.class);
    }

    @Deprecated
    public static MultiSignerERC7913 load(String contractAddress, Web3j web3j,
            Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        return new MultiSignerERC7913(contractAddress, web3j, credentials, gasPrice, gasLimit);
    }

    @Deprecated
    public static MultiSignerERC7913 load(String contractAddress, Web3j web3j,
            TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        return new MultiSignerERC7913(contractAddress, web3j, transactionManager, gasPrice, gasLimit);
    }

    public static MultiSignerERC7913 load(String contractAddress, Web3j web3j,
            Credentials credentials, ContractGasProvider contractGasProvider) {
        return new MultiSignerERC7913(contractAddress, web3j, credentials, contractGasProvider);
    }

    public static MultiSignerERC7913 load(String contractAddress, Web3j web3j,
            TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        return new MultiSignerERC7913(contractAddress, web3j, transactionManager, contractGasProvider);
    }

    public static RemoteCall<MultiSignerERC7913> deploy(Web3j web3j, Credentials credentials,
            ContractGasProvider contractGasProvider) {
        return deployRemoteCall(MultiSignerERC7913.class, web3j, credentials, contractGasProvider, getDeploymentBinary(), "");
    }

    @Deprecated
    public static RemoteCall<MultiSignerERC7913> deploy(Web3j web3j, Credentials credentials,
            BigInteger gasPrice, BigInteger gasLimit) {
        return deployRemoteCall(MultiSignerERC7913.class, web3j, credentials, gasPrice, gasLimit, getDeploymentBinary(), "");
    }

    public static RemoteCall<MultiSignerERC7913> deploy(Web3j web3j,
            TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        return deployRemoteCall(MultiSignerERC7913.class, web3j, transactionManager, contractGasProvider, getDeploymentBinary(), "");
    }

    @Deprecated
    public static RemoteCall<MultiSignerERC7913> deploy(Web3j web3j,
            TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        return deployRemoteCall(MultiSignerERC7913.class, web3j, transactionManager, gasPrice, gasLimit, getDeploymentBinary(), "");
    }

    public static void linkLibraries(List<Contract.LinkReference> references) {
        librariesLinkedBinary = linkBinaryWithReferences(BINARY, references);
    }

    private static String getDeploymentBinary() {
        if (librariesLinkedBinary != null) {
            return librariesLinkedBinary;
        } else {
            return BINARY;
        }
    }

    public static class ERC7913SignerAddedEventResponse extends BaseEventResponse {
        public byte[] signers;
    }

    public static class ERC7913SignerRemovedEventResponse extends BaseEventResponse {
        public byte[] signers;
    }

    public static class ERC7913ThresholdSetEventResponse extends BaseEventResponse {
        public BigInteger threshold;
    }
}
